import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            arr[i] = num;
        }

        int max = arr[0];
        int min = arr[0];
        for (int i = 1; i < n; i++) {
            if(max < arr[i]){
                max = arr[i];
            }
            if(min > arr[i]){
                min = arr[i];
            }
        }
        max -= min;
        System.out.println(max);
    }
    public static void main4(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            arr[i] = num;
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += arr[i];
        }
        System.out.println(sum);
    }
    public static void main3(String[] args) {
        int a = 0, b = 0,i = 0;
        Scanner scanner = new Scanner(System.in);
        int[] arr = new int[10];
        for (i = 0; i < 10; i++) {
            int num = scanner.nextInt();
            arr[i] = num;
        }
        for (i = 0; i < 10; i++) {
            if (arr[i] > 0) {
                b++;
            }
            else if (arr[i] < 0) {
                a++;
            }
        }
        System.out.println("positive:" + b);
        System.out.println("negative:" + a);
    }
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            char a = in.next().charAt(0);
            if (a >= 'A' && a <= 'Z') {
                System.out.printf("%c\n", a+32);
            } else {
                System.out.printf("%c\n", a-32);
            }
        }
    }
    public static void main1(String[] args){
        int a = 0, b = 0, i = 0, j = 0;

        Scanner scanner = new Scanner(System.in);

        a = scanner.nextInt();
        int[] arr=new int[a+1];
        for ( i = 0; i < arr.length - 1 ; i++) {
            int z = scanner.nextInt();
            arr[i]= z;
        }
         b = scanner.nextInt();


        if (arr[a - 1] < b) {
            arr[a] = b;
        }
        else {
            for (i = 0; i < a; i++) {
                if (b < arr[i]) {
                    for (j = a; j > i; j--) {
                        arr[j] = arr[j - 1];
                    }
                    arr[j] = b;
                }
            }
        }
        for ( i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}